# vim: set filetype=python :

import os
import SCons

Import('env')

libs=['tmv'] 
sblibs=['tmv_symband','tmv']

env1 = env.Clone(CPPDEFINES=[],LIBS=libs+env['LIBS'])

# Include the shared library location within the executable.
lib_install_dir = os.path.join(env['FINAL_PREFIX'], 'lib')
if env['SHARED']:
    if 'install' in COMMAND_LINE_TARGETS:
        env1.Append( RPATH = Dir(lib_install_dir).abspath )
    else:
        env1.Append( RPATH = Dir('#lib').abspath )

    # Workaround for SCons bug: The above doesn't always work correctly.
    # RPATH clashes with LINKFLAGS.  So if LINKFLAGS is already set, we need this workaround.
    # See: http://scons.tigris.org/issues/show_bug.cgi?id=1644
    # Fixed in version 2.1.
    major , minor, junk = SCons.__version__.split('.',2)
    if major < 2 or (major == 2 and minor == 0):
        env1.Append( LINKFLAGS = ["$__RPATH"] )
    if env['PREFIX'] != '':
        env1.AppendUnique(LIBPATH=os.path.join(env['FINAL_PREFIX'], 'lib'))

if env['MEM_DEBUG']:
  env1.Append(CPPDEFINES=['TMV_MEM_DEBUG'])

env2 = env1.Clone(LIBS=sblibs+env['LIBS'])

vector = env1.Program('vector','Vector.cpp')
matrix = env1.Program('matrix','Matrix.cpp')
division = env1.Program('division','Division.cpp')
bandmatrix = env2.Program('bandmatrix','BandMatrix.cpp')
symmatrix = env2.Program('symmatrix','SymMatrix.cpp')

env.Alias(target='examples',
    source=[vector,matrix,division,bandmatrix,symmatrix])

